package hari4.tes.soal3;

public class ParkingBuilding {	
	
	public static void main(String[] args) {
		System.out.print("Enter vehicle type [1.Car , 2.Motor] :");
	 	int n = Integer.parseInt(BacaKeyboard.bacaString());
	 		 	
	 	System.out.print("Enter start time:");	 	
	 	String startTime = BacaKeyboard.bacaString();
	 	
	 	System.out.print("Enter end time:");
	 	String endTime = BacaKeyboard.bacaString();
	
		
		int jedaStartTime = startTime.indexOf(":");		
		String jamStartTime = startTime.substring(0, jedaStartTime);
		int intJamStartTime = Integer.parseInt(jamStartTime);
		String menitStartTime = startTime.substring(jedaStartTime+1);
		int intMenitStartTime = Integer.parseInt(menitStartTime);
				
		int jedaEndTime = endTime.indexOf(":");
		String jamEndTime = endTime.substring(0, jedaEndTime);
		int intJamEndTime = Integer.parseInt(jamEndTime);
		String menitEndTime = endTime.substring(jedaEndTime+1);
		int intMenitEndTime = Integer.parseInt(menitEndTime);
		
		int differenceMenit, differenceJam ;
		
		differenceJam = intJamEndTime - intJamStartTime;
		differenceMenit = intMenitEndTime - intMenitStartTime;
		
		if(differenceMenit < 0) {differenceJam--; differenceMenit = 60 + differenceMenit;}  
		if(differenceJam < 0) {differenceJam = 24 + differenceJam;}
		
		if(differenceJam == 0) System.out.println("Time Difference: " + differenceMenit + " minutes");
		else System.out.println("Time Difference: " + differenceJam + " hour "+ differenceMenit + " minutes");
				
		int fee=0;
	//	int jam = selisihWaktu/60;
	//	int menit = selisihWaktu-(jam*60);
		
		if(n==1) 
			fee = 2000;
		else if(n== 2) 
			fee = 1500;
		
		differenceJam = differenceJam-2; // 2 jam pertama
		if(differenceJam<=0 && differenceMenit>0) {
			if(n==1) 
				fee += 1000;
			else if(n==2) 
				fee += 500;
		}else if(differenceJam>0) {
			if(n==1) 
				fee += (differenceJam*1000);
			else if(n==2) 
				fee += (differenceJam*500);
		}
		
		System.out.println("total fee: "+fee);
		
		
		int res = 0;
		if(n==1&&fee>=8000)
			res = 8000;
		else if(n==2&&fee>=4000)
			res = 4000;
		else
			res = fee;
		System.out.println("charge: "+res);
				
//		int fee = hitungFee(vhcl, selisihWaktu);
//		int charge = hitungCharge(vhcl, fee);
	 	
	 	
	}
}
